<template>
    <div class="user_body">
        <div class="user_">
            <div class="container">
                <div class="inner-box">
                    <div class="top-section">
                        <div class="user_content">
                            <div class="user_image_container">
                                <img v-if="studentData.image" :src="studentData.image" alt="Image Description">
                                <img v-else src="https://img47.photophoto.cn/20180426/0470063083396323_s.jpg" alt="">
                            </div>
                        </div>
                        <div class="user_text_container">
                            <span class="user_text">Cherish(珎){{ studentData.name }}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <div class="user_img">
                                <a href="#/name" class="user_img1" style="text-decoration: none;">
                                <img src="https://css.eenet.com/onlineschool_eenet_fe/images/common/icon_enter@2x.png"
                                    alt="">
                                <span v-if="studentData.idCardType != 1">去实名</span>
                                <span v-else>已实名</span>
                            </a>
                            </div>
                            <a href="#/my" class="user_img2" style="text-decoration: none;">
                                <img src="https://css.eenet.com/onlineschool_eenet_fe/images/common/person-icon-blue.png"
                                    alt="">
                                <span>个人信息</span>
                            </a>
                        </div>
                        <div class="learn_">
                            &nbsp;&nbsp;&nbsp;&nbsp;<span><a href="#/learn" style="text-decoration: none;">想学</a>
                                &nbsp;&nbsp;| </span> &nbsp;&nbsp;&nbsp;
                            <span><a href="#/history" style="text-decoration: none;">浏览记录</a></span>
                        </div>
                    </div>
                    <div class="bottom-section">
                        <div class="left-section">
                            <div class="order-details">
                                <span class="myOrder"><a href="#/userOrder" style="text-decoration: none;">我的报名 ></a></span>
                            </div>
                            <div class="tool-button">
                                <div>
                                    <el-button type="text" @click="goNotFound" class="tool-button1">
                                        <el-image
                                            src="https://css.eenet.com/onlineschool_eenet_fe/images/common/icon_order_unpay.png"
                                            fit="cover" style="vertical-align: middle;"></el-image>
                                        <span class="button-text">待付款</span>
                                    </el-button>
                                    <el-button type="text" @click="goNotFound" class="tool-button1">
                                        <el-image
                                            src="https://css.eenet.com/onlineschool_eenet_fe/images/common/icon_order_unenter.png"
                                            fit="cover" style="vertical-align: middle;"></el-image>
                                        <span class="button-text">待入学</span>
                                    </el-button>
                                    <el-button type="text" class="tool-button1" @click="dialogFormVisibleAdd = true">
                                        <el-image
                                            src="https://css.eenet.com/onlineschool_eenet_fe/images/common/icon_order_enter.png"
                                            fit="cover" style="vertical-align: middle;"></el-image>
                                        <span class="button-text">已入学</span>
                                    </el-button>
                                </div>
                            </div>
                        </div>
                        <div class="right-section">
                            <div class="order-details">
                                <span class="myOrder"><a style="text-decoration: none;">学程管理 ></a></span>
                            </div>
                            <div class="tool-button">
                                <div>
                                    <el-button type="text" @click="goNotFound" class="tool-button1">
                                        <el-image
                                            src="https://css.eenet.com/onlineschool_eenet_fe/images/common/icon_order_active.png"
                                            fit="cover" style="vertical-align: middle;"></el-image>
                                        <span class="button-text">进行中</span>
                                    </el-button>
                                    <el-button type="text" @click="goNotFound" class="tool-button1">
                                        <el-image
                                            src="https://css.eenet.com/onlineschool_eenet_fe/images/common/icon_order_finish.png"
                                            fit="cover" style="vertical-align: middle;"></el-image>
                                        <span class="button-text">已完成</span>
                                    </el-button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div style="height: 10ox;background-color: #F5F7F9;margin-top: 10px;"><span style="color:#F5F7F9 ;">a</span>
            </div>
            <div class="user_more">
                <div class="user_more_text">
                    更多服务
                </div>
                <div class="user_setup">
                    <a href="#/setup" style="text-decoration: none;color: black;"><i class="el-icon-setting">系统设置</i>
                    </a>
                </div>
            </div>
            <home-view></home-view>
        </div>
    </div>
</template>
    
<script>
import { jwtDecode } from 'jwt-decode';
import HomeView from '@/views/HomeView.vue';

export default {
    components: {
        HomeView,
    },
    data() {
        return {
            studentData: [],//学生数据
        };
    },
    computed: {

    },
    methods: {// 跳转到学生管理页面
        goNotFound() {
            this.$message.error("该功能正在完善中");
        }
    },

    mounted() {
        const jwt = localStorage.getItem('jwt');
        if (jwt) {
            const decoded = jwtDecode(jwt);
            const userId = decoded.id; // 确保你的token结构中有id字段
            this.$http.get("/api/students/queryOneStudentById/" + userId).then(response => {  /*刷新页面*/
                this.studentData = response.data.data;
            }).catch(() => {
                this.$message.error("请求错误");
            });
            this.$http.get("/api/orders/queryOneStudentOrder/" + userId).then(response => {  /*刷新页面*/
                this.orderData = response.data.data.rows;
            }).catch(() => {
                this.$message.error("请求错误");
            });
        }
    },
};
</script>
    
<style>
@import "@/style/user.css";
</style>